<template>
  <div>
    <el-table :data="tableData" border style="width: 100%" class="list">
      <el-table-column prop="name" label="特产名" width="70"></el-table-column>
      <el-table-column prop="description" label="特产描述" width="150"></el-table-column>
      <el-table-column prop="main_img" label="封面图" width="230">
        <template slot-scope="scope">
          <el-image style="width: 200px; height: 100px" :src="scope.row.main_img"></el-image>
        </template>
      </el-table-column>
      <el-table-column prop="stars" label="评分" width="50"></el-table-column>
      <el-table-column prop="amount" label="数量" width="50"></el-table-column>
      <el-table-column prop="price" label="总价" width="50"></el-table-column>
      <el-table-column prop="price_discount" label="折后价" width="70"></el-table-column>
      <el-table-column prop="id" label="交易id" width="70"></el-table-column>
      <el-table-column prop="user_name" label="用户昵称" width="100"></el-table-column>
      <el-table-column prop="phone" label="电话" width="120"></el-table-column>
      <el-table-column prop="date" label="预约的时间" width="120"></el-table-column>
      <el-table-column prop="status" label="订单状态" width="80"></el-table-column>
      <el-table-column prop="create_time" label="下单时间" width="120"></el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="small" @click="$emit('change',scope.$index)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "appointmentList",
  props: ["appointmentList"],
  computed: {
    tableData: function() {
      return this.appointmentList.filter((item, index) => {
        if (item.status == 1) {
          item.status = "已领取";
        } else if (item.status == 0) {
          item.status == "未领取";
        } else if (item.status == 2) {
          item.status == "已领取";
        }
        item.index = index;
        return true;
      });
    }
  },
  methods: {
    handleEdit(index, row) {
      alert(index, row);
    }
  }
};
</script>

<style lang="scss" scopted>
* {
  text-align: center;
}
.list {
  height: 70vh;
  overflow-y: scroll;
  text-align: center;
  &::before {
    display: none;
  }
}
</style>